﻿using DemoQLKhoSX.DatabaseAccessLayer;
using DemoQLKhoSX.EntityClasses;
using System;
using System.Collections.Generic;
using System.Data;
using System.Text;

namespace DemoQLKhoSX.BusinessLogicLayer
{
    public class ThuKhoBLO
    {
        private ThuKhoDAO _thukhoDAO;

        public ThuKhoBLO()
        {
            _thukhoDAO = new ThuKhoDAO();
        }

        public ThuKhoEntity getThuKhoByID(string id)
        {
            ThuKhoEntity thukho = new ThuKhoEntity();
            DataTable tbl = new DataTable();
            tbl = _thukhoDAO.searchByID(id);

            if (tbl != null)
                foreach (DataRow r in tbl.Rows)
                {
                    thukho.IDThuKHo = id;
                    thukho.TenThuKho = r["TenThuKho"].ToString();
                    thukho.ChucTrach = r["ChucTrach"].ToString();
                }
            return thukho;
        }

        public List<ThuKhoEntity> getThuKho()
        {
            List<ThuKhoEntity> ThuKho = new List<ThuKhoEntity>();
            DataTable tbl = new DataTable();
            tbl = _thukhoDAO.searchByID("");

            if (tbl != null)
                foreach (DataRow r in tbl.Rows)
                {
                    ThuKhoEntity nThuKho = new ThuKhoEntity();
                    nThuKho.ChucTrach = r["ChucTrach"].ToString();
                    nThuKho.IDThuKHo = r["IDThuKHo"].ToString();
                    nThuKho.TenThuKho = r["TenThuKho"].ToString();
                    ThuKho.Add(nThuKho);
                }
            return ThuKho;
        }
    }
}
